# 3-14 用Python实现双端队列
class Deque(object):
    def __init__(self):
        self.items = []

    def addFront(self, item):
        self.items.insert(0, item)

    def addRear(self, item):
        self.items.append(item)

    def removeFront(self):
        return self.items.pop(0)

    def removeRear(self):
        return self.items.pop()

    def isEmpty(self):
        return self.items == []

    def size(self):
        return len(self.items)


d = Deque()
print(d.isEmpty())  # True
d.addRear(4)
d.addRear("cat")
d.addRear(True)
print(d.items)  # [4, 'cat', True]
print(d.size())  # 3
print(d.isEmpty())  # False
d.addRear(8.4)
print(d.items)  # [4, 'cat', True, 8.4]
print(d.removeRear())  # 8.4
print(d.removeFront())  # 4
